define(function (require, exports, module) {
	$("#getPhoneCodeEdit").click(function(){   	
		var _that = this;
		$.get('../../../app/security/getPaypwdCode.html', function(data) {
			if(data.resCode==1){
				get_code_time(_that);				
			}
			layer.alert(data.resMsg);
			
		});
    });
	
	$("#updatePwdForm").validate({
        rules: {
           'newPayPwd': {
                required: true,
				regexPassword:true
            },
            'confirmNewPayPwd': {
                required: true,
				equalTo: "#newPayPwd"
            },
            'code':{
            	required: true,
            	rangelength:[6,6]
            }
        },
        messages: {
        	'newPayPwd': {
            	required: "至少8到16位英文和数字",
				regexPassword:'新密码格式错误'
            },
            'confirmNewPayPwd': {
            	required: "请再输一次新密码",
				equalTo: "两次密码不一致"
            },
            'code':{
            	required: "请输入手机验证码",
            	rangelength:"验证码必须是6位"
            }
        },
        submitHandler: function (form, event, validator) {
            $(form).ajaxSubmit(function (data) {
                var code = data.resCode;
                if (code==1) {
            		window.location.href = "/mobile/usercenter/security/setting.html";                	
                } else {
                    layer.alert(data.resMsg);
                }
            });
        }
    });
	
	var wait = 60;
	get_code_time = function (elem) {
		if (wait == 0) {
			$(elem).text("重新发送");
			$(elem).next().hide();
			$(elem).show();
			wait = 60;
		} else {
			$(elem).next().text("("+wait+")秒后重新获取");
			$(elem).hide();
			$(elem).next().show();
			wait--;
			setTimeout(function() {
				get_code_time(elem);
			}, 1000);
		}
	};
});